home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / QuickDraw / CopyBits vs. CopyMask / Sample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-18  |  19.6 KB  |  590 lines  |  [TEXT/KAHL]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.c    -    C Source (main segment)
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89
  18. #                1.03                06/89
  19. #                1.04                06/92
  20. #
  21. #    Components:
  22. #                Sample.p            June 1, 1989
  23. #                Sample.c            June 1, 1989
  24. #                SampleInit.c        June 2, 1992
  25. #                Sample.a            June 1, 1989
  26. #                Sample.inc1.a        June 1, 1989
  27. #                SampleMisc.a        June 1, 1989
  28. #                Sample.r            June 1, 1989
  29. #                Sample.h            June 1, 1989
  30. #                PSample.make        June 1, 1989
  31. #                CSample.make        June 1, 1989
  32. #                ASample.make        June 1, 1989
  33. #                CSample.π            June 2, 1992
  34. #                CSample.π.rsrc        June 2, 1992
  35. #
  36. #    Sample is an example application that demonstrates how to
  37. #    initialize the commonly used toolbox managers, operate 
  38. #    successfully under MultiFinder, handle desk accessories, 
  39. #    and create, grow, and zoom windows.
  40. #
  41. #    It does not by any means demonstrate all the techniques 
  42. #    you need for a large application. In particular, Sample 
  43. #    does not cover exception handling, multiple windows/documents, 
  44. #    sophisticated memory management, printing, or undo. All of 
  45. #    these are vital parts of a normal full-sized application.
  46. #
  47. #    This application is an example of the form of a Macintosh 
  48. #    application; it is NOT a template. It is NOT intended to be 
  49. #    used as a foundation for the next world-class, best-selling, 
  50. #    600K application. A stick figure drawing of the human body may 
  51. #    be a good example of the form for a painting, but that does not 
  52. #    mean it should be used as the basis for the next Mona Lisa.
  53. #
  54. #    We recommend that you review this program or TESample before 
  55. #    beginning a new application.
  56. #
  57. ------------------------------------------------------------------------------*/
  58.  
  59.  
  60. /* Segmentation strategy:
  61.  
  62.    This program consists of three segments.
  63.    1. "Main" contains most of the code, including the MPW libraries, and the
  64.       main program.  This segment is in the file Sample.c
  65.    2. "Initialize" contains code that is only used once, during startup, and
  66.       can be unloaded after the program starts.  This segment is in the file
  67.       SampleInit.c.
  68.    3. "%A5Init" is automatically created by the Linker to initialize globals
  69.       for the MPW libraries and is unloaded right away. */
  70.  
  71.  
  72. /* SetPort strategy:
  73.  
  74.    Toolbox routines do not change the current port. In spite of this, in this
  75.    program we use a strategy of calling SetPort whenever we want to draw or
  76.    make calls which depend on the current port. This makes us less vulnerable
  77.    to bugs in other software which might alter the current port (such as the
  78.    bug (feature?) in many desk accessories which change the port on OpenDeskAcc).
  79.    Hopefully, this also makes the routines from this program more self-contained,
  80.    since they don't depend on the current port setting. */
  81.  
  82. #pragma segment Main
  83.  
  84. #include <limits.h>
  85. #include "Test.h"
  86. #include "Sample.h"        /* bring in all the #defines for Sample */
  87.  
  88. /* The "g" prefix is used to emphasize that a variable is global. */
  89.  
  90. /* GMac is used to hold the result of a SysEnvirons call. This makes
  91.    it convenient for any routine to check the environment. */
  92. SysEnvRec    gMac;                /* set up by Initialize */
  93.  
  94. /* GHasWaitNextEvent is set at startup, and tells whether the WaitNextEvent
  95.    trap is available. If it is false, we know that we must call GetNextEvent. */
  96. Boolean        gHasWaitNextEvent;    /* set up by Initialize */
  97.  
  98. /* GInBackground is maintained by our osEvent handling routines. Any part of
  99.    the program can check it to find out if it is currently in the background. */
  100. Boolean        gInBackground;        /* maintained by Initialize and DoEvent */
  101.  
  102.  
  103. /* The following globals are the state of the window. If we supported more than
  104.    one window, they would be attatched to each document, rather than globals. */
  105.  
  106. /* GStopped tells whether the stop light is currently on stop or go. */
  107. Boolean        gStopped;            /* maintained by Initialize and SetLight */
  108.  
  109. /* GStopRect and gGoRect are the rectangles of the two stop lights in the window. */
  110. Rect        gStopRect;            /* set up by Initialize */
  111. Rect        gGoRect;            /* set up by Initialize */
  112.  
  113.  
  114. /* Define HiWrd and LoWrd macros for efficiency. */
  115. #define HiWrd(aLong)    (((aLong) >> 16) & 0xFFFF)
  116. #define LoWrd(aLong)    ((aLong) & 0xFFFF)
  117.  
  118. /* Define TopLeft and BotRight macros for convenience. Notice the implicit
  119.    dependency on the ordering of fields within a Rect */
  120. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  121. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  122.  
  123.  
  124.  
  125.  
  126. void main()
  127. {
  128.     /* 1.01 - call to ForceEnvirons removed */
  129.     
  130.     /*    If you have stack requirements that differ from the default,
  131.         then you could use SetApplLimit to increase StackSpace at 
  132.         this point, before calling MaxApplZone. */
  133.     MaxApplZone();                    /* expand the heap so code segments load at the top */
  134.  
  135.     Initialize();                    /* initialize the program */
  136.     UnloadSeg((Ptr) Initialize);    /* note that Initialize must not be in Main! */
  137.  
  138.     EventLoop();                    /* call the main event loop */
  139. }
  140.  
  141.  
  142. /*    Get events forever, and handle them by calling DoEvent.
  143.     Get the events by calling WaitNextEvent, if it's available, otherwise
  144.     by calling GetNextEvent. Also call AdjustCursor each time through the loop. */
  145.  
  146. void EventLoop()
  147. {
  148.     RgnHandle    cursorRgn;
  149.     Boolean        gotEvent;
  150.     EventRecord    event;
  151.     Point        mouse;
  152.  
  153.     cursorRgn = NewRgn();            /* we’ll pass WNE an empty region the 1st time thru */
  154.     do {
  155.         /* use WNE if it is available */
  156.         if ( gHasWaitNextEvent ) {
  157.             GetGlobalMouse(&mouse);
  158.             AdjustCursor(mouse, cursorRgn);
  159.             gotEvent = WaitNextEvent(everyEvent, &event, LONG_MAX, nil);
  160.         }
  161.         else {
  162.             SystemTask();
  163.             gotEvent = GetNextEvent(everyEvent, &event);
  164.         }
  165.  
  166.         if ( gotEvent ) {
  167.             /* make sure we have the right cursor before handling the event */
  168.             AdjustCursor(event.where, cursorRgn);
  169.  
  170.             if (FrontWindow() && IsDialogEvent(&event)) {
  171.                 HandleDialogEvent(&event);
  172.             } else {
  173.                 HandleNormalEvent(&event);
  174.             }
  175.         }
  176.  
  177.         /*    If you are using modeless dialogs that have editText items,
  178.             you will want to call IsDialogEvent to give the caret a chance
  179.             to blink, even if WNE/GNE returned FALSE. However, check FrontWindow
  180.             for a non-NIL value before calling IsDialogEvent. */
  181.  
  182.     } while ( true );    /* loop forever; we quit via ExitToShell */
  183. } /*EventLoop*/
  184.  
  185.  
  186. /* Do the right thing for an event. Determine what kind of event it is, and call
  187.  the appropriate routines. */
  188.  
  189. void HandleNormalEvent(EventRecord *event)
  190. {
  191.     short        part, err;
  192.     WindowPtr    window;
  193.     Boolean        hit;
  194.     char        key;
  195.     Point        aPoint;
  196.  
  197.     switch ( event->what ) {
  198.         case mouseDown:
  199.             part = FindWindow(event->where, &window);
  200.             switch ( part ) {
  201.                 case inMenuBar:                /* process a mouse menu command (if any) */
  202.                     AdjustMenus();
  203.                     DoMenuCommand(MenuSelect(event->where));
  204.                     break;
  205.                 case inSysWindow:            /* let the system handle the mouseDown */
  206.                     SystemClick(event, window);
  207.                     break;
  208.                 case inContent:
  209.                     if ( window != FrontWindow() ) {
  210.                         SelectWindow(window);
  211.                         /*HandleNormalEvent(event);*/    /* use this line for "do first click" */
  212.                     } else
  213.                         DoContentClick(window);
  214.                     break;
  215.                 case inDrag:                /* pass screenBits.bounds to get all gDevices */
  216.                     DragWindow(window, event->where, &qd.screenBits.bounds);
  217.                     break;
  218.                 case inGrow:
  219.                     break;
  220.                 case inZoomIn:
  221.                 case inZoomOut:
  222.                     hit = TrackBox(window, event->where, part);
  223.                     if ( hit ) {
  224.                         SetPort(window);                /* the window must be the current port... */
  225.                         EraseRect(&window->portRect);    /* because of a bug in ZoomWindow */
  226.                         ZoomWindow(window, part, true);    /* note that we invalidate and erase... */
  227.                         InvalRect(&window->portRect);    /* to make things look better on-screen */
  228.                     }
  229.                     break;
  230.             }
  231.             break;
  232.         case keyDown:
  233.         case autoKey:                        /* check for menukey equivalents */
  234.             key = event->message & charCodeMask;
  235.             if ( event->modifiers & cmdKey )            /* Command key down */
  236.                 if ( event->what == keyDown ) {
  237.                     AdjustMenus();                        /* enable/disable/check menu items properly */
  238.                     DoMenuCommand(MenuKey(key));
  239.                 }
  240.             break;
  241.         case activateEvt:
  242.             DoActivate((WindowPtr) event->message, (event->modifiers & activeFlag) != 0);
  243.             break;
  244.         case updateEvt:
  245.             DoUpdate((WindowPtr) event->message);
  246.             break;
  247.         /*    1.01 - It is not a bad idea to at least call DIBadMount in response
  248.             to a diskEvt, so that the user can format a floppy. */
  249.         case diskEvt:
  250.             if ( HiWord(event->message) != noErr ) {
  251.                 SetPt(&aPoint, kDILeft, kDITop);
  252.                 err = DIBadMount(aPoint, event->message);
  253.             }
  254.             break;
  255.         case kOSEvent:
  256.         /*    1.02 - must BitAND with 0x0FF to get only low byte */
  257.             switch ((event->message >> 24) & 0x0FF) {        /* high byte of message */
  258.                 case kSuspendResumeMessage:        /* suspend/resume is also an activate/deactivate */
  259.                     gInBackground = (event->message & kResumeMask) == 0;
  260.                     DoActivate(FrontWindow(), !gInBackground);
  261.                     break;
  262.             }
  263.             break;
  264.     }
  265. } /*HandleNormalEvent*/
  266.  
  267. void HandleDialogEvent(EventRecord *event)
  268. {
  269.     OSErr        err;
  270.     char        key;
  271.     Point        aPoint;
  272.     short         itemHit;
  273.     DialogPtr    dialog;
  274.  
  275.     switch ( event->what ) {
  276.         case keyDown:
  277.         case autoKey:                        /* check for menukey equivalents */
  278.             key = event->message & charCodeMask;
  279.             if ( event->modifiers & cmdKey )            /* Command key down */
  280.                 if ( event->what == keyDown ) {
  281.                     AdjustMenus();                        /* enable/disable/check menu items properly */
  282.                     DoMenuCommand(MenuKey(key));
  283.                 }
  284.             break;
  285.         case diskEvt:
  286.             if ( HiWord(event->message) != noErr ) {
  287.                 SetPt(&aPoint, kDILeft, kDITop);
  288.                 err = DIBadMount(aPoint, event->message);
  289.             }
  290.             break;
  291.         default:
  292.             if (DialogSelect(event, &dialog, &itemHit)) {
  293.                 if (itemHit == kReadySetGoButton) {
  294.                     LetTheGameBegin(dialog);
  295.                 }
  296.             }
  297.     }
  298. }
  299.  
  300. /*    Change the cursor's shape, depending on its position. This also calculates the region
  301.     where the current cursor resides (for WaitNextEvent). If the mouse is ever outside of
  302.     that region, an event would be generated, causing this routine to be called,
  303.     allowing us to change the region to the region the mouse is currently in. If
  304.     there is more to the event than just “the mouse moved”, we get called before the
  305.     event is processed to make sure the cursor is the right one. In any (ahem) event,
  306.     this is called again before we     fall back into WNE. */
  307.  
  308. void AdjustCursor(Point mouse, RgnHandle region)
  309. {
  310.     WindowPtr    window;
  311.     RgnHandle    arrowRgn;
  312.     RgnHandle    plusRgn;
  313.     Rect        globalPortRect;
  314.  
  315.     window = FrontWindow();    /* we only adjust the cursor when we are in front */
  316.     if ( (! gInBackground) && (! IsDAWindow(window)) ) {
  317.     }
  318. } /*AdjustCursor*/
  319.  
  320.  
  321. /*    Get the global coordinates of the mouse. When you call OSEventAvail
  322.     it will return either a pending event or a null event. In either case,
  323.     the where field of the event record will contain the current position
  324.     of the mouse in global coordinates and the modifiers field will reflect
  325.     the current state of the modifiers. Another way to get the global
  326.     coordinates is to call GetMouse and LocalToGlobal, but that requires
  327.     being sure that thePort is set to a valid port. */
  328.  
  329. void GetGlobalMouse(Point *mouse)
  330. {
  331.     EventRecord    event;
  332.     
  333.     OSEventAvail(kNoEvents, &event);    /* we aren't interested in any events */
  334.     *mouse = event.where;                /* just the mouse position */
  335. } /*GetGlobalMouse*/
  336.  
  337.  
  338. /*    This is called when an update event is received for a window.
  339.     It calls DrawWindow to draw the contents of an application window.
  340.     As an effeciency measure that does not have to be followed, it
  341.     calls the drawing routine only if the visRgn is non-empty. This
  342.     will handle situations where calculations for drawing or drawing
  343.     itself is very time-consuming. */
  344.  
  345. void DoUpdate(WindowPtr window)
  346. {
  347.     if ( IsAppWindow(window) ) {
  348.         BeginUpdate(window);                /* this sets up the visRgn */
  349.         if ( ! EmptyRgn(window->visRgn) )    /* draw if updating needs to be done */
  350.             DrawWindow(window);
  351.         EndUpdate(window);
  352.     }
  353. } /*DoUpdate*/
  354.  
  355.  
  356. /*    This is called when a window is activated or deactivated.
  357.     In Sample, the Window Manager's handling of activate and
  358.     deactivate events is sufficient. Other applications may have
  359.     TextEdit records, controls, lists, etc., to activate/deactivate. */
  360.  
  361. void DoActivate(WindowPtr window, Boolean becomingActive)
  362. {
  363.     if ( IsAppWindow(window) ) {
  364.         if ( becomingActive )
  365.             /* do whatever you need to at activation */ ;
  366.         else
  367.             /* do whatever you need to at deactivation */ ;
  368.     }
  369. } /*DoActivate*/
  370.  
  371.  
  372. /*    This is called when a mouse-down event occurs in the content of a window.
  373.     Other applications might want to call FindControl, TEClick, etc., to
  374.     further process the click. */
  375.  
  376. void DoContentClick(WindowPtr window)
  377. {
  378. } /*DoContentClick*/
  379.  
  380.  
  381. /* Draw the contents of the application window. We do some drawing in color, using
  382.    Classic QuickDraw's color capabilities. This will be black and white on old
  383.    machines, but color on color machines. At this point, the window’s visRgn
  384.    is set to allow drawing only where it needs to be done. */
  385.  
  386. void DrawWindow(WindowPtr window)
  387. {
  388.     SetPort(window);
  389. } /*DrawWindow*/
  390.  
  391.  
  392. /*    Enable and disable menus based on the current state.
  393.     The user can only select enabled menu items. We set up all the menu items
  394.     before calling MenuSelect or MenuKey, since these are the only times that
  395.     a menu item can be selected. Note that MenuSelect is also the only time
  396.     the user will see menu items. This approach to deciding what enable/
  397.     disable state a menu item has the advantage of concentrating all
  398.     the decision-making in one routine, as opposed to being spread throughout
  399.     the application. Other application designs may take a different approach
  400.     that is just as valid. */
  401.  
  402. void AdjustMenus()
  403. {
  404.     WindowPtr    window;
  405.     MenuHandle    menu;
  406.  
  407.     window = FrontWindow();
  408.  
  409.     menu = GetMHandle(mFile);
  410.     if ( IsDAWindow(window) )        /* we can allow desk accessories to be closed from the menu */
  411.         EnableItem(menu, iClose);
  412.     else
  413.         DisableItem(menu, iClose);    /* but not our traffic light window */
  414.  
  415.     menu = GetMHandle(mEdit);
  416.     if ( IsDAWindow(window) ) {        /* a desk accessory might need the edit menu… */
  417.         EnableItem(menu, iUndo);
  418.         EnableItem(menu, iCut);
  419.         EnableItem(menu, iCopy);
  420.         EnableItem(menu, iClear);
  421.         EnableItem(menu, iPaste);
  422.     } else {                        /* …but we don’t use it */
  423.         DisableItem(menu, iUndo);
  424.         DisableItem(menu, iCut);
  425.         DisableItem(menu, iCopy);
  426.         DisableItem(menu, iClear);
  427.         DisableItem(menu, iPaste);
  428.     }
  429. } /*AdjustMenus*/
  430.  
  431.  
  432. /*    This is called when an item is chosen from the menu bar (after calling
  433.     MenuSelect or MenuKey). It performs the right operation for each command.
  434.     It is good to have both the result of MenuSelect and MenuKey go to
  435.     one routine like this to keep everything organized. */
  436.  
  437. void DoMenuCommand(long menuResult)
  438. {
  439.     short        menuID;                /* the resource ID of the selected menu */
  440.     short        menuItem;            /* the item number of the selected menu */
  441.     short        itemHit;
  442.     Str255        daName;
  443.     short        daRefNum;
  444.     Boolean        handledByDA;
  445.  
  446.     menuID = HiWord(menuResult);    /* use macros for efficiency to... */
  447.     menuItem = LoWord(menuResult);    /* get menu item number and menu number */
  448.     switch ( menuID ) {
  449.         case mApple:
  450.             switch ( menuItem ) {
  451.                 case iAbout:        /* bring up alert for About */
  452.                     itemHit = Alert(rAboutAlert, nil);
  453.                     break;
  454.                 default:            /* all non-About items in this menu are DAs */
  455.                     /* type Str255 is an array in MPW 3 */
  456.                     GetItem(GetMHandle(mApple), menuItem, daName);
  457.                     daRefNum = OpenDeskAcc(daName);
  458.                     break;
  459.             }
  460.             break;
  461.         case mFile:
  462.             switch ( menuItem ) {
  463.                 case iClose:
  464.                     DoCloseWindow(FrontWindow());
  465.                     break;
  466.                 case iQuit:
  467.                     Terminate();
  468.                     break;
  469.             }
  470.             break;
  471.         case mEdit:                    /* call SystemEdit for DA editing & MultiFinder */
  472.             handledByDA = SystemEdit(menuItem-1);    /* since we don’t do any Editing */
  473.             break;
  474.     }
  475.     HiliteMenu(0);                    /* unhighlight what MenuSelect (or MenuKey) hilited */
  476. } /*DoMenuCommand*/
  477.  
  478.  
  479.  
  480. /* Close a window. This handles desk accessory and application windows. */
  481.  
  482. /*    1.01 - At this point, if there was a document associated with a
  483.     window, you could do any document saving processing if it is 'dirty'.
  484.     DoCloseWindow would return true if the window actually closed, i.e.,
  485.     the user didn’t cancel from a save dialog. This result is handy when
  486.     the user quits an application, but then cancels the save of a document
  487.     associated with a window. */
  488.  
  489. Boolean DoCloseWindow(WindowPtr window)
  490. {
  491.     if ( IsDAWindow(window) )
  492.         CloseDeskAcc(((WindowPeek) window)->windowKind);
  493.     else if ( IsAppWindow(window) )
  494.         CloseWindow(window);
  495.     return true;
  496. } /*DoCloseWindow*/
  497.  
  498.  
  499. /**************************************************************************************
  500. *** 1.01 DoCloseBehind(window) was removed ***
  501.  
  502.     1.01 - DoCloseBehind was a good idea for closing windows when quitting
  503.     and not having to worry about updating the windows, but it suffered
  504.     from a fatal flaw. If a desk accessory owned two windows, it would
  505.     close both those windows when CloseDeskAcc was called. When DoCloseBehind
  506.     got around to calling DoCloseWindow for that other window that was already
  507.     closed, things would go very poorly. Another option would be to have a
  508.     procedure, GetRearWindow, that would go through the window list and return
  509.     the last window. Instead, we decided to present the standard approach
  510.     of getting and closing FrontWindow until FrontWindow returns NIL. This
  511.     has a potential benefit in that the window whose document needs to be saved
  512.     may be visible since it is the front window, therefore decreasing the
  513.     chance of user confusion. For aesthetic reasons, the windows in the
  514.     application should be checked for updates periodically and have the
  515.     updates serviced.
  516. **************************************************************************************/
  517.  
  518.  
  519. /* Clean up the application and exit. We close all of the windows so that
  520.  they can update their documents, if any. */
  521.  
  522. /*    1.01 - If we find out that a cancel has occurred, we won't exit to the
  523.     shell, but will return instead. */
  524.  
  525. void Terminate()
  526. {
  527.     WindowPtr    aWindow;
  528.     Boolean        closed;
  529.     
  530.     closed = true;
  531.     do {
  532.         aWindow = FrontWindow();                /* get the current front window */
  533.         if (aWindow != nil)
  534.             closed = DoCloseWindow(aWindow);    /* close this window */    
  535.     }
  536.     while (closed && (aWindow != nil));
  537.  
  538.     if (closed)
  539.         ExitToShell();                            /* exit if no cancellation */
  540. } /*Terminate*/
  541.  
  542. /*    Check to see if a window belongs to the application. If the window pointer
  543.     passed was NIL, then it could not be an application window. WindowKinds
  544.     that are negative belong to the system and windowKinds less than userKind
  545.     are reserved by Apple except for windowKinds equal to dialogKind, which
  546.     mean it is a dialog.
  547.     1.02 - In order to reduce the chance of accidentally treating some window
  548.     as an AppWindow that shouldn't be, we'll only return true if the windowkind
  549.     is userKind. If you add different kinds of windows to Sample you'll need
  550.     to change how this all works. */
  551.  
  552. Boolean IsAppWindow(WindowPtr window)
  553. {
  554.     short        windowKind;
  555.  
  556.     if ( window == nil )
  557.         return false;
  558.     else {    /* application windows have windowKinds = userKind (8) */
  559.         windowKind = ((WindowPeek) window)->windowKind;
  560.         return ( windowKind == userKind || windowKind == dialogKind);
  561.     }
  562. } /*IsAppWindow*/
  563.  
  564.  
  565. /* Check to see if a window belongs to a desk accessory. */
  566.  
  567. Boolean IsDAWindow(WindowPtr window)
  568. {
  569.     if ( window == nil )
  570.         return false;
  571.     else    /* DA windows have negative windowKinds */
  572.         return ( ((WindowPeek) window)->windowKind < 0 );
  573. } /*IsDAWindow*/
  574.  
  575.  
  576. /*    Display an alert that tells the user an error occurred, then exit the program.
  577.     This routine is used as an ultimate bail-out for serious errors that prohibit
  578.     the continuation of the application. Errors that do not require the termination
  579.     of the application should be handled in a different manner. Error checking and
  580.     reporting has a place even in the simplest application. The error number is used
  581.     to index an 'STR#' resource so that a relevant message can be displayed. */
  582.  
  583. void AlertUser()
  584. {
  585.     short        itemHit;
  586.  
  587.     SetCursor(&qd.arrow);
  588.     itemHit = Alert(rUserAlert, nil);
  589.     ExitToShell();
  590. } /* AlertUser */